package com.atguigu.gulimall.product.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement//开启事务管理
@MapperScan("com.atguigu.gulimall.product.dao")
public class MybatisConfig {

    /**
     * 为什么页面不显示数据条数，就配置分页插件？
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        //请求页>最大页  true回到首页，false返回空数据
        paginationInterceptor.setOverflow(true);
        //设置最大单页数量，默认500条，-1不限
        paginationInterceptor.setLimit(1000);
        return paginationInterceptor;
    }

}
